package com.xpgk.mvc.budgetYear;

import java.util.List;

import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.bstockHandover.StockTransfer;
import com.xpgk.mvc.codeSet.Code;
import com.xpgk.mvc.organization.Organization;

public class BudgetYearController extends  BaseController{
		
	private  BudgetYearService  budgetYearService;
	
	
		public void index() {
			Organization  o=Organization.dao.findById(getCUserOrganIds());
			setAttr("organization", o);
			setAttr("lcIds", Code.lc_ids);
			render("budgetYear.html");
		}
		
		/**查询产品预算
		 * 
		 */
		public  void  getBudget()
		{
			String json = paging(splitPage, Budget.sqlId_splitPageSelect, Budget.sqlId_splitPageFrom);
			renderJson(json);
		}
		
		/**保存产品年预算
		 * 
		 */
		@Before(Tx.class)
		public  void saveBudget()
		{
//			List<BudgetDetail>  bdList=getModels(BudgetDetail.class);
//			List<BudgetDetail>  bdList1=getModels(BudgetDetail.class,"budgetDetail1");
			String  oldNum=getPara("oldNum");
			String  nowNum=getPara("nowNum");
			String  nextNum=getPara("nextNum");
			String  budgetJson=getPara("budgetJson");
			String msg=budgetYearService.saveBudget(oldNum,nowNum,nextNum,budgetJson,getCUserOrganIds(),getCUserIds());
			renderText(msg);
		}

}
